//package com.kun.comm;
//
//import com.alibaba.fastjson.JSON;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//import org.springframework.web.multipart.MultipartFile;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//
//@Aspect
//@Component
//public class LogAspect {
//
//    private static final Logger logger = LoggerFactory.getLogger(LogAspect.class);
//
//    @Pointcut("execution(* com.isuwang..*.controller..*.*(..))")
//    public void logging() {
//    }
//
//    @Around("logging()")
//    public Object invoked(ProceedingJoinPoint point) throws Throwable {
//        ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//        HttpServletRequest request = sra.getRequest();
//
//        List<Object> argList = new ArrayList<>();
//
//        //get请求参数
//        Map getParam = request.getParameterMap();
//        if (!getParam.isEmpty()) {
//            argList.add(getParam);
//        }
//
//        //其他请求参数
//        Object[] args = point.getArgs();
//        if (args.length > 0) {
//            for (int i = 0; i < args.length; i++) {
//                // 排除不能序列化的参数
//                if (!(args[i] instanceof HttpSession) && !(args[i] instanceof HttpServletRequest)
//                        && !(args[i] instanceof HttpServletResponse) && !(args[i] instanceof MultipartFile)) {
//                    argList.add(args[i]);
//                }
//            }
//        }
//
//        logger.info("请求开始==> method:{}, url:{}, 请求参数：{}", request.getMethod(), request.getRequestURL(), JSON.toJSONString(argList));
//
//        Long start = System.currentTimeMillis();
//        Object result = point.proceed();
//        Long end = System.currentTimeMillis();
//
//        logger.info("请求结束，耗费时间：{}毫秒， 响应：{}", end - start, JSON.toJSONString(result));
//        return result;
//    }
//}
